package com.lqian.qian_clone;

/**
 * 浅克隆测试
 * @author：Melody_LQ
 * @time：2022/9/1 9:51 下午
 */
public class QianCloneTest {
    public static void main(String[] args) throws CloneNotSupportedException {
        Student student = new Student(1,"Jack");
        //原型对象
        Teacher teacher = new Teacher(student,18);
        //克隆
        Teacher clone = teacher.clone();
        //true ： 代表student都是指向原型对象的地址
        System.out.println(teacher.getStudent() == clone.getStudent());

        //赋克隆对象的值
        clone.getStudent().setAge(3);
        System.out.println(teacher);
        System.out.println(clone);
        System.out.println("原型对象和克隆对象是否相等:"+(teacher == clone));

    }
}
